import { Module } from '@nestjs/common'
import { AuthService } from './auth.service'
import { LocalStrategy } from './local.strategy'
import { JwtStrategy } from './jwt.strategy'
import { UsersModule } from '../users/users.module'
import { UserInfoModule } from '../user-info/user-info.module'
import { PassportModule } from '@nestjs/passport'
import { JwtModule } from '@nestjs/jwt'
import { jwtConstants } from './constants'
import { AuthController } from './auth.controller'
import { User } from 'src/entity/User'
import { UserInfo } from 'src/entity/Userinfo'
import { TypeOrmModule } from '@nestjs/typeorm'

@Module({
  imports: [
    UsersModule,
    UserInfoModule,
    PassportModule,
    // JWT令牌注册
    JwtModule.register({
      secret: jwtConstants.secret,
      // 过期时间 1200s 20分钟
      signOptions: { expiresIn: '1200s' },
    }),
    TypeOrmModule.forFeature([User, UserInfo]),
  ],
  controllers: [AuthController],
  providers: [AuthService, LocalStrategy, JwtStrategy],
  exports: [AuthService],
})
export class AuthModule { }
